home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-09-09 | 2.1 KB | 78 lines | [TEXT/MPCC] |
- /*---------------------------------------------------------------
- Copyright 1995, Steve Israelson
-
- I own this code. You are free to use this code in any software
- you want. You may not sell this source code at all, you can
- sell your product though. If you want to include this code
- in any code collection (CD-Roms etc) this is OK as long as
- I get a complimentary copy.
- Steve.
-
- Regular expressions.
- ---------------------------------------------------------------*/
- #pragma once
-
- #include <LList.h>
-
- class RegExp
- {
- public:
- enum {
- kReg_Once, // match only once
- kReg_ZeroOrMore, // match 0 or more times
- kReg_OneOrMore // match one or more times
- };
- RegExp *next; // the expression that follows this one
- long ID; // an identifier for this expression
- short type; // a type from the above enumeration
- Boolean parameter; // do we need to return our match?
-
- static RegExp *Parse(char *text, RegExp*, long exprID);
- RegExp(long newID);
- ~RegExp();
-
- Boolean Match(char *text, short start, short *last, LList *paramList);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class RBeginLine : public RegExp
- {
- public:
- RBeginLine(char *text, long newID);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class REndLine : public RegExp
- {
- public:
- REndLine(char *text, long newID);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class RSetExpr : public RegExp
- {
- public:
- char charSet[256]; // ascii allows for only 256 chars, right?
-
- RSetExpr(char *text, long newID);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class RAnyChar : public RegExp
- {
- public:
- RAnyChar(char *text, long newID);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class ROrExpr : public RegExp
- {
- public:
- ROrExpr(char *text, long newID);
- virtual Boolean MatchOne(char *text, short start, short *end);
- };
-
- class RLiteral : public RegExp
- {
- public:
- char buffer[256]; // literals